package com.hlt.meta.controller;

import com.hlt.meta.entity.User;
import com.hlt.meta.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.websocket.server.PathParam;


@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserService userService;

    @RequestMapping(value = "/get/{id}",method = RequestMethod.GET)
    public User Get(@PathVariable(value="id") String id){
        int userId = Integer.parseInt(id);
        User user =userService.getUserById(userId);
        return user;
    }

    @RequestMapping("/create")
    public User Create(@RequestBody User user)
    {
        userService.addUser(user);
        return user;
    }

}
